// ml278
// Copyright (C) 2008 Bjørn Øivind Bjørnsen, Aleksander Gjermundsen, Knut Andre Tidemann, Thomas Hansen
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

#ifndef __PLANETARYOPTIONS_H_
#define __PLANETARYOPTIONS_H_

#include <Ogre.h>

namespace Ogre
{
	class PlanetarySceneManager;

	/**
	 * A Class to give a simple interface to contents of planetary-configfiles.
	 * This loads all the valid information in the given configfile, and stores it internally in the object,
	 * to be accessed by other classes by getting a pointer to the relevant object through the PlanetarySceneManager.
	*/
	class PlanetaryOptions
	{
	public:
		PlanetaryOptions(PlanetarySceneManager *mgr);

		void setDefaults();
		void load(DataStreamPtr &stream);

		/// Vertex rows per tile
		unsigned int TileSize;
		/// Tile rows per page
		unsigned int PageSize;
		/// Page rows per zone
		unsigned int ZoneSize;
		
		/// Whether the atmosphere is enabled or not
		bool mAtmosphere;
		/// Whether to draw debug-colours of every-second tile. @note the material applied must have
		/// lightning disabled for this to work.
		bool mTileDebugSquares;

		/// Scaling to apply to the heightmap-data
		float mTerrainScale;

		/// Position of the planet
		Vector3 mPlanetPosition;
		
		/// Radius of the planet
		float mPlanetRadius;
		
		/// mass of the planet
		float mPlanetMass;

		/// Size of one side of the heightmap for a page renderable
		unsigned int mPageSizeLOD1;
		
		/// Size of one side of the heightmap for a zone renderable
		unsigned int mZoneSizeLOD1;

		/// Used to check when to change from tiles to page rendering
		float mPageRenderableLODDistance;

		/// Used to check when to change from pages to zone rendering
		float mZoneToPageLODDistance;

		/// Load a frame every this ammout of frames
		unsigned int mPageLoadFrequency;

		/// Unload a page if not used for this ammount of frames
		unsigned int mPageUnloadFrequency;

		/// Number of tile LODs
		unsigned int mNumerOfTilesLODs;
		/// Size of one of the 6 atmosphere zones at LOD level 0
		unsigned int mAtmoSizeLOD0;
		/// Size of one of the 6 atmosphere zones at LOD level 1
		unsigned int mAtmoSizeLOD1;
		/// Size of one of the 6 atmosphere zones at LOD level 2
		unsigned int mAtmoSizeLOD2;
		
		/// Distance from the planetsurface that we start to use LOD 0
		Real mAtmoLOD0Distance;
		/// Distance from the planetsurface that we start to use LOD 1
		Real mAtmoLOD1Distance;
		/// Distance from the planetsurface that we start to use LOD 2
		Real mAtmoLOD2Distance;

		/// unique name of the planet
		String mPlanetName;
		/// unique name of the heightmaps
		String mHeightmapName;
		/// Which material to use for the ground of the planet
		String mPlanetMaterial;
		/// Which material to use for the atmosphere given that it is enabled
		String mAtmosphereMaterial;

		PlanetarySceneManager *mSceneMgr;
	};
}

#endif
